﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _22._04.CS
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void esegui(string daLettera,
      string aLettera)
        {
            NorthWindEntities db =
               new NorthWindEntities();
            var contatti = from c in db.Clienti
                           where (c.Nome.Substring(0,
                             1).CompareTo(daLettera) >= 0)
                             && (c.Nome.Substring(0, 1).CompareTo(aLettera) <= 0)
                           orderby c.Nome, c.Cognome
                           select new
                           {
                               c.Nome,
                               c.Cognome
                           };
            DataGridView1.DataSource = contatti;
        }

        private void Button1_Click(object sender, EventArgs e)
        {
            esegui("A", "Z");
        }

        private void A_Click(object sender, EventArgs e)
        {
            esegui("A", "G");
        }

        private void B_Click(object sender, EventArgs e)
        {
            esegui("H", "P");
        }

        private void C_Click(object sender, EventArgs e)
        {
            esegui("Q", "Z");
        }
    }
}
